package com.heima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.heima.dto.pagedto.TransferPageDto;
import com.heima.mapper.TransferMapper;
import com.heima.pojo.Transfer;
import com.heima.result.PageResult;
import com.heima.service.TransferService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class TransferServiceImpl implements TransferService {

    @Autowired
    private TransferMapper transferMapper;


    /**
     * 分页查询
     * @param dto
     * @return
     */
    @Override
    public PageResult queryTransferList(TransferPageDto dto) {
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        Page<Transfer> page =transferMapper.queryTransferList(dto);
        long total = page.getTotal();
        List<Transfer> result = page.getResult();

        return new PageResult(total,result,HttpServletResponse.SC_OK,"查询成功",null);
    }

}
